import table from '@/components/dt/table/render.js'
import Opt from '@/components/dt/info/Opt.js'

let _this = null

class Column extends Opt {
  constructor(vm) {
    super()
    _this = vm
    this.build()
  }

  build() {
    this.createAll()
    this.opts.push(...this.all)
  }

  createAll() {
    console.log(_this.curState, 'curState')
    this.all = []
    let publicArr = [{
      title: '序号',
      type: 'index',
      width: 70,
      align: 'center',
    }, {
      title: '所属组织',
      field: 'orgName',
      minWidth: 120
    },
    {
      title: '案场名称',
      field: 'housesName',
      minWidth: 120
    },
    {
      title: '合作类型',
      field: 'cooperationMode',
      minWidth: 120
    },
    {
      title: '所属产品',
      field: 'productName',
      minWidth: 150
    },
    {
      title: '房源名称',
      field: 'roomName',
      minWidth: 150
    },
    {
      title: '订单类型',
      field: 'orderType',
      minWidth: 200
    },
    {
      title: '所属顾问',
      field: 'counselorName',
      minWidth: 220
    },
    {
      title: '客户姓名',
      field: 'customerName',
      minWidth: 180
    },
    {
      title: '提交人',
      field: 'createName',
      minWidth: 180
    },
    {
      title: '提交日期',
      field: 'createTime',
      minWidth: 150,
      slots: {
        default: (params, h) => {
          return params.row.createTime ? params.row.createTime.split(' ')[0] : ''
        }
      }
    }, ]

    let waitAuditArr = [{
      title: '操作',
      fixed: 'right',
      minWidth: 150,
      align: 'center',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '查看',
            event: 'viewFun',
            data: params.row
          })
          btns.push({
            title: _this.unlocking('0206080100') ? '审核' : '',
            event: 'auditFun',
            data: params.row
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }]
    let passAuditArr = [
    {
      title: '审批人',
      field: 'auditName',
      minWidth: 120
    },
    {
      title: '审批日期',
      field: 'auditTime',
      minWidth: 180,
    },
    {
      title: '操作',
      fixed: 'right',
      minWidth: 150,
      align: 'center',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '查看',
            event: 'viewFun',
            data: params.row
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }]
    let rejectAuditArr = [
    {
      title: '审批人',
      field: 'auditName',
      minWidth: 120
    },
    {
      title: '审批时间',
      field: 'auditTime',
      minWidth: 180
    },
    {
      title: '驳回原因',
      field: 'auditReason',
      minWidth: 220
    },
    {
      title: '操作',
      fixed: 'right',
      minWidth: 150,
      align: 'center',
      slots: {
        default: (params, h) => {
          let btns = []
          btns.push({
            title: '查看',
            event: 'viewFun',
            data: params.row
          })
          return table.cell.btns(_this, h, btns)
        }
      }
    }]
    if (_this.curState == '0') {
      this.all.push(...publicArr, ...waitAuditArr)
    } else if (_this.curState == '1') {
      this.all.push(...publicArr, ...passAuditArr)
    } else if (_this.curState == '2') {
      this.all.push(...publicArr, ...rejectAuditArr)
    }
  }

}

export default Column